package com.ruoyi.platform.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.platform.domain.TbFare;
import com.ruoyi.platform.service.ITbFareService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 乘客端APP优化Controller
 * 
 * @author ruoyi
 * @date 2025-08-18
 */
@RestController
@RequestMapping("/fare")
public class TbFareController extends BaseController
{
    @Autowired
    private ITbFareService tbFareService;

    /**
     * 查询乘客端APP优化列表
     */
    //@RequiresPermissions("platform:fare:list")
    @GetMapping("/list")
    public TableDataInfo list(TbFare tbFare)
    {
        startPage();
        List<TbFare> list = tbFareService.selectTbFareList(tbFare);
        return getDataTable(list);
    }

    /**
     * 导出乘客端APP优化列表
     */
    //@RequiresPermissions("platform:fare:export")
    @Log(title = "乘客端APP优化", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbFare tbFare)
    {
        List<TbFare> list = tbFareService.selectTbFareList(tbFare);
        ExcelUtil<TbFare> util = new ExcelUtil<TbFare>(TbFare.class);
        util.exportExcel(response, list, "乘客端APP优化数据");
    }

    /**
     * 获取乘客端APP优化详细信息
     */
    //@RequiresPermissions("platform:fare:query")
    @GetMapping(value = "/{fareId}")
    public AjaxResult getInfo(@PathVariable("fareId") Long fareId)
    {
        return success(tbFareService.selectTbFareByFareId(fareId));
    }

    /**
     * 新增乘客端APP优化
     */
    //@RequiresPermissions("platform:fare:add")
    @Log(title = "乘客端APP优化", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbFare tbFare)
    {
        return toAjax(tbFareService.insertTbFare(tbFare));
    }

    /**
     * 修改乘客端APP优化
     */
    //@RequiresPermissions("platform:fare:edit")
    @Log(title = "乘客端APP优化", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbFare tbFare)
    {
        return toAjax(tbFareService.updateTbFare(tbFare));
    }

    /**
     * 删除乘客端APP优化
     */
    //@RequiresPermissions("platform:fare:remove")
    @Log(title = "乘客端APP优化", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fareIds}")
    public AjaxResult remove(@PathVariable Long[] fareIds)
    {
        return toAjax(tbFareService.deleteTbFareByFareIds(fareIds));
    }
}
